<!-- eslint-disable no-undef -->
<script setup lang="ts">
import type { ConsultOrderItem } from '@/types/consult'
import type { PopoverAction } from 'vant'
const props = defineProps<{
  item: ConsultOrderItem
}>()
const emits = defineEmits<{
  (e: 'delOrder', v: ConsultOrderItem): void
  (e: 'showpreInfo', v: string): void
}>()
const showPopover = ref(false)
const actions = computed(() => [
  { text: '查看处方', disabled: !props.item.prescriptionId },
  { text: '删除订单' }
])
const onSelect = (action: PopoverAction, i: number) => {
  console.log('点击气泡项触发的方法', action, i)
  // 点击了气泡中的删除按钮 删除订单
  if (i === 1) {
    // delOrder(props.item)
    emits('delOrder', props.item)
  }
  // 查看处方
  if (i === 0) {
    // showpreInfo(props.item.prescriptionId)
    emits('showpreInfo', props.item.prescriptionId!)
  }
}
</script>
<template>
  <div class="more">
    <van-popover
      v-model:show="showPopover"
      :actions="actions"
      @select="onSelect"
      placement="top-start"
    >
      <template #reference> 更多 </template>
    </van-popover>
  </div>
</template>

<style scoped>
.more {
  color: var(--cp-tag);
  flex: 1;
  font-size: 13px;
}
</style>
